// 封装所有请求操作
import axios from '../../index'
import qs from 'qs'

// let api = 'http://192.168.221.230:8080'
// let api = 'http://118.190.210.28:8080'
// let api = 'http://192.168.221.242:8080'


// 查询订单列表
export const OrderListAxios = (params) => {
    return axios({
        url: '/orders/queryOrderList',
        method: 'GET',
        params: {
            currentPage: params.currentPage, // 页数
            pageSize: params.pageSize, // 一页的数据总量
        }
    })
}

// 今日新增
export const AddOrderDayAxios = (params) => {
    return axios({
        url: '/orders/queryTodayOrders',
        method: 'GET',
        params: {
            currentPage: params.currentPage,
            pageSize: params.pageSize
        }
    })
}
// 本周新增
export const AddOrderWeekAxios = (params) => {
    return axios({
        url: '/orders/queryWeekOrders',
        method: 'GET',
        params: {
            currentPage: params.currentPage,
            pageSize: params.pageSize
        }
    })
}

// 本月新增
export const AddOrderMonthAxios = (params) => {
    return axios({
        url: '/orders/queryMonthOrders',
        method: 'GET',
        params: {
            currentPage: params.currentPage,
            pageSize: params.pageSize
        }
    })
}

// 搜索
export const SearchOrderAxios = (params) =>  {
    // console.log('params',params);
    return axios({
        url: '/orders/search',
        method: 'GET',
        params: {
            currentPage: params.currentPage,
            pageSize: params.pageSize,
            conn: params.val
        }
    })
}

// 删除订单接口
export const DelOrderAxios = (value, order_id) => {
    return axios({
        url: '/orders/delete',
        method: 'POST',
        data: qs.stringify({
            value,
            order_id,
            status: 2
        })
    })
}

// 点击客户名称查看该客户详细信息
export const CheckCustomerAxios = (params) => {
    return axios({
        url: '/orders/queryByCustomer_id',
        method: 'GET',
        params: {
            customer_id: params.customer_id,
            currentPage: params.currentPage,
            pageSize: params.pageSize,
        }

    })
}


// 修改订单状态
export const ChangeOrderStatusAxios = (status, order_id) => {
    return axios({
        url: '/orders/updatStatus',
        method: 'POST',
        data: qs.stringify({
            status,
            order_id
        })

    })
}

// 修改发货状态
export const ChangeshippingStatusAxios = (shippingStatus, order_id) => {
    return axios({
        url: '/orders/updatShippingStatus',
        method: 'POST',
        data: qs.stringify({
            shippingStatus,
            order_id
        })

    })
}

// 点击订单商品显示该订单详情
export const ShowOrderGoodsAxios = (params) => {
    return axios({
        url: '/orders/queryOrderGoods',
        method: 'GET',
        params: {
            currentPage: params.currentPage,
            pageSize: params.pageSize,
            order_id: params.orderId
        }

    })
}

// 新增订单的第一个界面显示客户信息
export const AddOrderAxios = (params) => {
    return axios({
        url: '/orders/addOrders',
        method: 'GET',
        params: {
            currentPage: params.currentPage,
            pageSize: params.pageSize,
        }
    })
}

// 删除商品订单
export const DelOrderGoodsAxios = (val, order_goods_id, order_id) => {
    return axios({
        url: '/orders/deleteOrderGoods',
        method: 'POST',
        data: qs.stringify({
            val,
            order_goods_id,
            order_id,
            order_goods_status: 2,
        })
    })
}

// 查询商品
export const QuueryOrderGoodsAxios = (params) => {
    return axios({
        url: '/orders/queryGoods',
        method: 'GET',
        params: {
            currentPage: params.currentPage,
            pageSize: params.pageSize,
        }
    })
}

// 查看订单信息
export const CheckOrderInfoAxios = (params) => {
    return axios({
        url: '/orders/queryByOrder_id',
        method: 'GET',
        params: {
            currentPage: params.currentPage,
            pageSize: params.pageSize,
            order_id: params.order_id
        }
    })
}



// 修改收款金额
export const EditOrderMoneyAxios = (received, order_id) => {
    return axios({
        url: '/orders/updateReceived',
        method: 'POST',
        data: qs.stringify({
            received,
            order_id
        })
    })
}

// 修改订单
export const EditOrderAxios = (params) => {
    return axios({
        url: '/orders/update',
        method: 'POST',
        data: {
            order_amount: params.order_amount,
            order_date: params.order_date,
            consignee: params.consignee,
            consignee_address: params.consignee_address,
            consignee_phone: params.consignee_phone,
            order_received: params.order_received,
            Submit_order_date: params.Submit_order_date,
            order_remark: params.order_remark,
            contact_id: params.contact_id,
            order_id: params.order_id
        }
    })
}

// 添加订单商品
export const AddOrderGoodsAxios = (params) => {
    return axios({
        url: '/orders/addGoodOrder',
        method: 'POST',
        data: qs.stringify({
            goods_id: params.goods_id,
            order_id: params.order_id
        })
    })
}

// 修改订单商品信息
export const EditOrderGoodsAxios = (params) => {
    return axios({
        url: '/orders/updateOrderGoods',
        method: 'POST',
        data: {
            order_goods_id: params.order_goods_id,
            order_id: params.order_id,
            order_goods_count: params.order_goods_count,
            discount: params.discount,
            order_goods_remark: params.order_goods_remark
        }
    })
}

// 新增订单
export const AddOrdersAxios = (params) => {
    return axios({
        url: '/orders/add',
        method: 'POST',
        data: {
            order_amount: params.order_amount,
            order_date: params.order_date,
            consignee: params.consignee,
            consignee_address: params.consignee_address,
            consignee_phone: params.consignee_phone,
            order_received: params.order_received,
            Submit_order_date: params.Submit_order_date,
            order_remark: params.order_remark,
            customer_Id: params.customer_Id,
            contact_id: params.contact_id,
            enter_time: params.enter_time
        }

    })
}


// 获取订单商品大分类和小分类
export const getBigGoodsAxios = (gt_id) => {
    return axios({
        url: '/purSelStock/queryGoodsType',
        method: 'POST',
        data: qs.stringify(
            {
                gt_id
            }
        )
    })
}

// 搜索订单商品请求
export const SearchGoodsAxios = (params) => {
    console.log('传递过去的数据', params);
    return axios({
        url: '/purSelStock/searchGoods',
        method: 'POST',
        data: qs.stringify(
            {
                currentPage: params.currentPage,
                goods_barcode: params.goods_barcode,
                goods_descript: params.goods_descript,
                goods_name: params.goods_name,
                gt_name: params.gt_name,
                gt_pno: params.gt_pno,
                pageSize: params.pageSize
            }
        )
    })
}
//联系人查询
export const getContactAxios = (customer_id) => {
    return axios({
        url: '/queryContact',
        method: 'POST',
        data: {
            customer_id
        }
    })
}